package com.labichaoka.chaoka.ui.home.fragment.home;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.CreditCardResponse;
import com.labichaoka.chaoka.entity.HomeInitResponse;
import com.labichaoka.chaoka.entity.VerifyInfoListResponse;

/**
 * Created by ruan on 2018/7/24.
 */

public class HomeFragmentPresenterImpl implements HomeFragmentPresenter,HomeFragmentInteractor.OnFinishedListener {
    private HomeFragmentView homeFragmentView;
    private HomeFragmentInteractor homeFragmentInteractor;

    public HomeFragmentPresenterImpl(HomeFragmentView view,HomeFragmentInteractor interactor){
        this.homeFragmentInteractor=interactor;
        this.homeFragmentView=view;
    }

    @Override
    public void init() {
        if (homeFragmentView!=null){
            homeFragmentView.showProgress();
        }
        homeFragmentInteractor.homeInit(this);
    }

    @Override
    public void getVerifyInfoList() {
        if (homeFragmentView!=null){
            homeFragmentView.showProgress();
        }
        homeFragmentInteractor.getVerifyInfoList(this);
    }

    @Override
    public void clearAuthInfo() {
        if (homeFragmentView!=null){
            homeFragmentView.showProgress();
        }
        homeFragmentInteractor.clearAuthInfo(this);
    }

    @Override
    public void resetUserStatus() {
        if (homeFragmentView!=null){
            homeFragmentView.showProgress();
        }
        homeFragmentInteractor.resetUserStatus(this);
    }

    @Override
    public void creditCardSwitch() {
        if (homeFragmentView!=null){
            homeFragmentView.showProgress();
        }
        homeFragmentInteractor.creditCardSwitch(this);
    }

    @Override
    public void onDestroy() {
        homeFragmentView=null;
    }

    @Override
    public void onSuccess(HomeInitResponse response) {
        homeFragmentView.hideProgress();
        homeFragmentView.setData(response);
    }

    @Override
    public void onFailed() {
        homeFragmentView.hideProgress();
    }

    @Override
    public void onGetVerifyInfoListSucc(VerifyInfoListResponse response) {
        homeFragmentView.hideProgress();
        homeFragmentView.getVerifyInfoListCallback(response);
    }

    @Override
    public void onGetVerifyInfoListFailed() {
        homeFragmentView.hideProgress();
    }

    @Override
    public void onClearAuthInfoSucc(BaseResponse response) {
        homeFragmentView.hideProgress();
        homeFragmentView.clearAuthInfo(response);
    }

    @Override
    public void onClearAuthInfoFailed() {
        homeFragmentView.hideProgress();
    }

    @Override
    public void onResetUserStatusSucc(BaseResponse response) {
        homeFragmentView.hideProgress();
        homeFragmentView.resetUserStatusCallback(response);
    }

    @Override
    public void onResetUserStatusFailed() {
        homeFragmentView.hideProgress();
    }

    @Override
    public void onCreditCardSucc(CreditCardResponse response) {
        homeFragmentView.hideProgress();
        homeFragmentView.creditCardSwitchCallback(response);
    }

    @Override
    public void onCreditCardFailed() {
        homeFragmentView.hideProgress();
    }
}
